/**
 * Alipay.com Inc.
 * Copyright (c) 2004-2014 All Rights Reserved.
 */
package com.h2o3.carmack.config;

import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionReaderUtils;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.beans.factory.xml.BeanDefinitionParser;
import org.springframework.beans.factory.xml.ParserContext;
import org.w3c.dom.Element;

import com.h2o3.carmack.message.MessageHandlerRegister;

/**
 * @author chensheng
 * @version $Id: AnnotationDrivenMessageHandlerDefinitionParser.java, v 0.1 2/10/14 5:09 AM chensheng Exp $
 */
public class AnnotationDrivenMessageHandlerDefinitionParser implements BeanDefinitionParser {
    @Override
    public BeanDefinition parse(Element element, ParserContext parserContext) {
        BeanDefinition beanDefinition = new RootBeanDefinition(MessageHandlerRegister.class);

        String beanName = BeanDefinitionReaderUtils.generateBeanName(beanDefinition,
            parserContext.getRegistry());

        parserContext.getRegistry().registerBeanDefinition(beanName, beanDefinition);

        return beanDefinition;
    }
}
